//
//  HZGoodsDetailViewPointModel.m
//  app
//
//  Created by 刘华舟 on 15/6/15.
//  Copyright (c) 2015年 hdaren. All rights reserved.
//

#import "HZGoodsDetailViewPointModel.h"

static const NSInteger kAvaterViewWidth = 88;
static const NSInteger kArrowBtnWidth = 40;

static const NSInteger contentTextMaxHeight = 10000;

@implementation HZGoodsDetailViewPointModel

+ (instancetype)modelWithDictionary:(NSDictionary *)dict{
    return [[HZGoodsDetailViewPointModel alloc] initModelWithDictionary:dict];
}

- (instancetype)initModelWithDictionary:(NSDictionary *)dict{
    if (self = [super init]) {
        _uid = [dict stringForKey:APIKEY_mall_uid nilValue:@"0"];
        _nicename = [dict stringForKey:APIKEY_mall_nickname nilValue:@""];
        _faceURL = [dict stringForKey:APIKEY_mall_face nilValue:@""];
        _contents = [dict stringForKey:APIKEY_mall_intros nilValue:@""];
        
        /** 去掉专家点评 -wirte by khzliu */
        //NSString *contentStr = [NSString stringWithFormat:@"专家观点：%@", _contents];
        NSString *contentStr = [NSString stringWithFormat:@"%@", _contents];
        
        NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:contentStr];
        [attributedString addAttribute:NSFontAttributeName value:JKAppGlobleFontSmallTagText range:NSMakeRange(0, [contentStr length])];
        
        CGSize contentTextSize = [contentStr boundingRectWithSize:[UBO_SCREEN fw:UB_WIDTH uw:-3*kSizeMallViewMargin-kAvaterViewWidth-kArrowBtnWidth uh:contentTextMaxHeight] options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:JKAppGlobleFontSmallTagText} context:nil].size;
        _open = NO;
        
        if (self.isOpen) {
            _veiwHeight = [UBO_SCREEN uh:kSizeMallViewMargin*2 oh:contentTextSize.height] > [UBO_SCREEN uh:kHZGoodsDetailViewPointHeight] ? [UBO_SCREEN uh:kSizeMallViewMargin*2 oh:contentTextSize.height]:[UBO_SCREEN uh:kHZGoodsDetailViewPointHeight];
            
            _contentLabelHeight = contentTextSize.height;
        }else{
            _veiwHeight = [UBO_SCREEN uh:kHZGoodsDetailViewPointHeight];
            
            _contentLabelHeight = [UBO_SCREEN uh:kSizeMallViewMargin*2 oh:contentTextSize.height] < [UBO_SCREEN uh:kHZGoodsDetailViewPointHeight] ? contentTextSize.height:[UBO_SCREEN uh:kHZGoodsDetailViewPointHeight-2*kSizeMallViewMargin];
        }
        
        //_veiwHeight = [UBO_SCREEN uh:kHZGoodsDetailViewPointHeight];
    }
    return self;
}


@end
